package com.cyf.plc.viewholder

import androidx.recyclerview.widget.RecyclerView
import com.cyf.plc.BR
import com.cyf.plc.adapter.FaultAdapter
import com.cyf.plc.databinding.ItemFaultBinding
import com.cyf.plc.model.PlcFault

class FaultViewHolder(private val binding: ItemFaultBinding) : RecyclerView.ViewHolder(binding.root) {

    fun bind(plcFault: PlcFault, onItemClickListener: FaultAdapter.OnItemClickListener? = null) {
        binding.setVariable(BR.plcFault, plcFault)

        onItemClickListener?.let { listener ->
            binding.root.setOnClickListener {
                listener.onItemClicked(plcFault)
            }
        }

    }
}